<template>
	<view class="container">
		<!-- 渐变背景 -->
		<view class="gradient-background"></view>
		
		<!-- 顶部安全区域 - 专为微信小程序设计 -->
		<view class="safe-area-top" :style="{ height: statusBarHeight + 'px' }"></view>
		
		<!-- 自定义导航栏 -->
		<view class="title-bar">
			<text class="title-text">生词本</text>
		</view>
		
		<!-- 切换按钮 -->
		<view class="toggle-buttons">
			<view class="button active">
				<text>正在复习</text>
			</view>
			<view class="button">
				<text>已掌握</text>
			</view>
		</view>
		
		<!-- 单词列表 -->
		<scroll-view 
			class="content-area" 
			scroll-y 
			:scroll-with-animation="true"
			:enhanced="true"
			:show-scrollbar="false"
			:bounces="true"
		>
			<view class="word-item completed">
				<view class="word-info">
					<text class="word">Conception</text>
					<text class="translation">n. 概念，观念</text>
					<view class="status-btn">
						<text>复习中</text>
					</view>
				</view>
				<view class="progress">
					<image src="/static/icon/progress.png" mode="aspectFit"></image>
					<text>50%</text>
				</view>
			</view>
			
			<view class="word-item uncompleted">
				<view class="word-info">
					<text class="word">Pitfall</text>
					<text class="translation">n. 陷阱，易犯的错误</text>
					<view class="status-btn">
						<text>下次复习: 50分钟</text>
					</view>
				</view>
				<view class="progress">
					<image src="/static/icon/progress.png" mode="aspectFit"></image>
					<text>32%</text>
				</view>
			</view>

			<view class="word-item completed">
				<view class="word-info">
					<text class="word">Swift</text>
					<text class="translation">adj. 迅速的，敏捷的</text>
					<view class="status-btn">
						<text>复习中</text>
					</view>
				</view>
				<view class="progress">
					<image src="/static/icon/progress.png" mode="aspectFit"></image>
					<text>60%</text>
				</view>
			</view>

			<view class="word-item uncompleted">
				<view class="word-info">
					<text class="word">Significant</text>
					<text class="translation">adj. 重要的，显著的</text>
					<view class="status-btn">
						<text>下次复习: 1小时</text>
					</view>
				</view>
				<view class="progress">
					<image src="/static/icon/progress.png" mode="aspectFit"></image>
					<text>74%</text>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				statusBarHeight: 0
			}
		},
		onLoad() {
			// #ifdef MP-WEIXIN
			// 获取状态栏高度
			const sysInfo = wx.getSystemInfoSync();
			this.statusBarHeight = sysInfo.statusBarHeight;
			// #endif
			
			// #ifndef MP-WEIXIN
			// 其他平台
			uni.getSystemInfo({
				success: (res) => {
					this.statusBarHeight = res.statusBarHeight;
				}
			});
			// #endif
		},
		onPageScroll(e) {
			e.preventDefault && e.preventDefault()
			return false
		}
	}
</script>

<style lang="scss">
page {
	height: 100%;
	overflow: hidden;
}

.container {
	display: flex;
	flex-direction: column;
	align-items: center;
	width: 100%;
	height: 100vh;
	background-color: #FFFFFF;
	position: relative;

	.gradient-background {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 40vh;
		background: linear-gradient(to bottom, #E4F2FF, #FFFFFF);
		z-index: 0;
	}
	
	/* 顶部安全区域 - 为状态栏预留空间 */
	.safe-area-top {
		width: 100%;
		background: transparent;
		position: relative;
		z-index: 99;
	}

	/* 标题栏 */
	.title-bar {
		width: 85%;
		height: 88rpx;
		margin: 80rpx 0rpx 0rpx 0rpx;
		display: flex;
		justify-content: flex-start;
		align-items: center;
		position: relative;
		z-index: 99;
		
		.title-text {
			font-size: 36rpx;
			font-weight: bold;
			color: #333;
			// margin-left: 10rpx;
		}
	}

	/* 切换按钮 */
	.toggle-buttons {
		width: 90%;
		display: flex;
		background-color: #F5F5F5;
		border-radius: 100rpx;
		padding: 8rpx;
		margin-bottom: 30rpx;
		z-index: 99;
		position: relative;

		.button {
			flex: 1;
			height: 64rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			border-radius: 100rpx;
			
			text {
				font-size: 28rpx;
				color: #666666;
			}

			&.active {
				background-color: #FFFFFF;
				box-shadow: 0 4rpx 8rpx rgba(0, 0, 0, 0.1);

				text {
					color: #333333;
					font-weight: 500;
				}
			}
		}
	}

	/* 内容区域 */
	.content-area {
		width: 90%;
		flex: 1;
		max-height: calc(100vh - 320rpx);
		padding-bottom: 40rpx;
		-webkit-overflow-scrolling: touch;
		position: relative;
		z-index: 98;

		.word-item {
			background-color: #FFFFFF;
			border-radius: 24rpx;
			padding: 30rpx;
			margin-bottom: 20rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.05);
			border: 1rpx solid transparent;

			&.completed {
				border-color: rgba(255, 149, 0, 0.6);

				.status-btn {
					background-color: #FF9500;
					padding: 12rpx 32rpx;
					border-radius: 100rpx;
					display: inline-block;

					text {
						color: #FFFFFF;
						font-size: 28rpx;
					}
				}
			}

			&.uncompleted {
				border-color: rgba(16, 121, 218, 0.6);

				.status-btn {
					background-color: #EEF7FF;
					padding: 12rpx 32rpx;
					border-radius: 100rpx;
					display: inline-block;

					text {
						color: #1079DA;
						font-size: 28rpx;
					}
				}
			}

			.word-info {
				flex: 1;
				display: flex;
				flex-direction: column;
				gap: 16rpx;

				.word {
					font-size: 36rpx;
					font-weight: 500;
					color: #333333;
				}

				.translation {
					font-size: 30rpx;
					font-weight: 400;
					color: #666666;
				}

				.status-btn {
					margin-top: 16rpx;
					align-self: flex-start;
				}
			}

			.progress {
				display: flex;
				flex-direction: column;
				align-items: center;
				gap: 8rpx;

				image {
					width: 80rpx;
					height: 80rpx;
				}

				text {
					font-size: 24rpx;
					color: #666666;
				}
			}
		}
	}
}
</style>
